package com.dingding.transfer.stamper.dto;

import com.dingding.transfer.stamper.constant.Code;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/3/31 19:12
 **/
public class BaseResultFactory {
    public static BaseResult<?> produceSuccess() {
        return new BaseResult<>(Code.SUCCESS);
    }

    public static BaseResult<?> produceError(){ return new BaseResult<>(Code.ERROR);}

    public static <T> BaseResult<T> produceSuccess(T data) {
        return new BaseResult<>(Code.SUCCESS, data);
    }

    public static BaseResult<?> produceEmptyResult(Code code) {
        return new BaseResult<>(code);
    }

    public static BaseResult<?> produceEmptyResult(Code code, String msg) {
        return new BaseResult<>(code.getCode(), msg);
    }

    public static BaseResult<?> produceEmptyResult(int codeInt, String msg) {
        return new BaseResult<>(codeInt, msg);
    }

    public static <T> BaseResult<T> produceResult(int codeInt, String msg, T data) {
        return new BaseResult<>(codeInt, msg, data);
    }

    public static <T> BaseResult<T> produceResult(Code code, T data) {
        return new BaseResult<>(code.getCode(), code.getMsg(), data);
    }

    public static void main(String[] args) {

    }
}
